unit ChildrenMdl;

interface
uses Classes, forms, SysUtils, patterns;

type
  TModelChildren = class(TObservable)
  private
    function iLikeIt: Boolean;
  public
    constructor Create;
    destructor Destroy; override;
    procedure response(cmd: string; const args: TCommand = nil; sargs: string = '');
  end;


implementation
uses commandlist, indexdef;

procedure TModelChildren.response(cmd: string; const args: TCommand = nil; sargs: string = '');
var
  p: PResponseInfo;
begin
  //you can add very complex logic code here
  new(p);
  p.CMD := cmd;

  if cmd = CMD_NODE_SELECT then
  begin
    p.response := 'I was selected!';
  end
  else if cmd = CMD_ALL_STOP_DRAWING then
  begin
    if lowercase(sargs) = 'father' then
    begin
      p.Response := ':-),Pretend not hearing it';
      p.ActualMean := 'You are not mum,you never punish me,hihi~~';
    end
    else if lowercase(sargs) = 'mother' then
    begin
      p.Response := 'Yes,OK';
      p.ActualMean := 'Hoops,';
    end
    else begin
      p.Response := ':-( Crying';
      p.ActualMean := 'scared';
    end;
  end
  else if cmd = CMD_MOM_NEWCLOTHES then
  begin
    if iLikeIt then
    begin
      p.Response := 'Yes,cool.I like it.';
      p.ActualMean := 'I like it.';
    end
    else begin
      p.Response := 'No,it"s ugly.';
      p.ActualMean := 'I dislike it.';
    end;
  end
  else if cmd = CMD_MOM_LOVEME then
  begin
    p.Response := 'Yes.';
    p.ActualMean := 'Yes.';
  end
  else if cmd = CMD_DAD_PLAYGAME then
  begin
    p.Response := 'Me!';
    p.ActualMean := 'Oh,Yeah!';
  end;

    //release p when command released
  self.Notify(TCommand.create(cmd, p));
end;

function TModelChildren.iLikeIt: Boolean;
begin
  result := random > 0.5;
end;

constructor TModelChildren.Create;
begin
end;

destructor TModelChildren.Destroy;
begin
  inherited;
end;


end.

